/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package calcul;

import java.util.Observable;
import vue.ObjetEchange;

/**
 * Calcule en mesurant le temps d'execution.
 * Le calcul tourne sur un thread a part (lance a chaque clic sur le bouton), 
 * distinct du thread de la GUI. Contient du code commun aux implementations 
 * single-thread et multi-thread.
 * @see MonteCarloSingle
 * @see MonteCarloMulti
 * @author Jo
 */
public abstract class MonteCarloAbstract extends Observable implements Runnable {
    
    double S=40, X=50, r=0.06, T=0.5, b=0.1, v=0.45;
    int nSteps = 168, nSimulations = 10000;
    double res=0;
    
    @Override
    public void run() {
        long debut = System.currentTimeMillis();
        
        res = MonteCarloStandardOption("c", S, X, T, r, b, v, nSteps, nSimulations);
        
        long fin = System.currentTimeMillis();
        
        setChanged();
        notifyObservers(new ObjetEchange(res, true, 100));
        System.out.println("Duree de calcul : " + (fin-debut) + "ms");
        System.out.println("Resultat : " + res + "$");
    }
    
    abstract double MonteCarloStandardOption ( String CallPutFlag, double S, double X, double T, 
            double r, double b, double v, int nSteps, int nSimulations);
}
